package com.eazyshop.goods.config;

import com.eazyshop.common.utils.IdWorker;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class IdWorkerConfig {
    // 注入雪花算法生成策略
    @Value("${workerId}")
    private String workerId;

    @Value("${datacenterId}")
    private String datacenterId;
    @Bean
    public IdWorker idWorkerSnowFloat(){
            long workLong = Long.parseLong(workerId);
        long dataCenterLong = Long.parseLong(datacenterId);
        return new IdWorker(workLong,dataCenterLong);
    }
}
